import constants
import sys
from configparser import ConfigParser
from suckrunner import SuckRunner

if __name__ == '__main__':
    print 'SuckPls %s\n' % constants.version
    if len(sys.argv) != 2:
        print '%s <configfile>' % sys.argv[0]
        exit()

    # Parse config.
    config_parser = ConfigParser()
    try:
        config_file = open(sys.argv[1])
        suck_calls = config_parser.parse_file(config_file)
    except:
        print sys.exc_info()  # TODO handle errors gracefully
        exit()

    runner = SuckRunner()
    runner.run(suck_calls)
